<template>
  <view class="container">
    <view class="example">
      <!-- 基础表单校验 -->
      <uni-forms ref="valiForm" :rules="rules" :modelValue="valiFormData">
        <uni-forms-item label="原始密码" required name="oldpwd">
          <uni-easyinput v-model="valiFormData.oldpwd" placeholder="请输入原始密码" />
        </uni-forms-item>
        <uni-forms-item label="新密码" required name="newpwd">
          <uni-easyinput v-model="valiFormData.newpwd" placeholder="请输入新密码" />
        </uni-forms-item>
        <uni-forms-item label="确认密码" required name="confrimwd">
          <uni-easyinput v-model="valiFormData.confrimwd" placeholder="请输入确认密码" />
        </uni-forms-item>
      </uni-forms>
      <button class="login-btn" type="default" @click="submit('valiForm')">确认</button>
    </view>
  </view>
</template>
<script>
	export default {
		data() {
			return {
				// 校验表单数据
				valiFormData: {
					oldpwd: '',
					newpwd: '',
					confrimwd: '',
				},
				// 校验规则
				rules: {
					oldpwd: {
						rules: [{
							required: true,
							errorMessage: '原始密码不能为空'
						}]
					},
					newpwd: {
						rules: [{
							required: true,
							errorMessage: '新密码不能为空'
						},]
					},
          confrimwd: {
						rules: [{
							required: true,
							errorMessage: '确认密码不能为空'
						},]
					}
				},
			}
		},
		computed: {
			
		},
		onLoad() {},
		methods: {
			submit(ref) {
				this.$refs[ref].validate().then(res => {
					console.log('success', res);
					uni.showToast({
						title: `修改成功`
					})
          uni.switchTab({url:'/pages/My/My',})
				}).catch(err => {
					console.log('err', err);
				})
			},
		}
	}
</script>
<style>

</style>